const { DataTypes } = require('sequelize')
const seq = require('../db/seq')
const Goods = require('./goods.model')

const Cart = seq.define('cart', {
    goods_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    user_id: {
        type: DataTypes.INTEGER,
        allowNull: false
    },
    number: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 1
    },
    selected: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: true
    }
})

Cart.belongsTo(Goods, {
    foreignKey: "goods_id",
    as: 'goods_info'
})
// Cart.sync({ force: true })
module.exports = Cart